package org.mlz.game.model

import org.itheima.kotlin.game.core.Painter
import org.mlz.game.Config
import org.mlz.game.business.Destroyable

/**
 *<p>
 *爆炸物
 *</p>
 * CreateBy  Malingzhao
 * @date  2020/9/21
 */
class Blast(override val x: Int, override val y: Int) : View, Destroyable {

    override val width: Int = Config.block
    override val height: Int = Config.block
    private val imagePaths = arrayListOf<String>()
    private var index: Int = 0

    init {
        (1..32).forEach {
            imagePaths.add("img/blast_${it}.png")
        }
    }

    override fun draw() {
        var i = index % imagePaths.size
        Painter.drawImage(imagePaths[i], x, y)
        index++

    }

    /**
     * 判断是否销毁了
     */
    override fun isDestroyed(): Boolean {

        return index >= imagePaths.size
    }

    /**
     * 死给你看的功能 ? 可以为空
     */
    override fun showDestroy(): Array<View>? {
        return null
    }

}
